import logging
import time
import grpc
import test_pb2
import test_pb2_grpc


def send_stream():
    message_list = ['1', '2', '3', '4', '5', '6', '7']
    for i in message_list:
        yield test_pb2.request(message=i)
        time.sleep(1)


def run():
    with grpc.insecure_channel("localhost:10086") as channel:
        client = test_pb2_grpc.StreamTestStub(channel)
        response = client.ClientStream(send_stream())
        print("返回结果：", response.message)


if __name__ == '__main__':
    logging.basicConfig()
    run()

